package org.quxiao.mmrsql.executor.mapper;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class TableJoinMapper extends Mapper<LongWritable, Text, Text, Text> {

	@Override
	protected void map(LongWritable key, Text value, Context context)
			throws IOException, InterruptedException {
		/* convert <tableName:id, attr> to <attr, tableName:id>
		 * input key	:	XXX
		 * input value 	:	tableName:id attribute
		 * output key	:	attribute
		 * output value	:	tableName:id
		 */
		String[] arr = value.toString().split(" ", 2);
		String tableAndId = arr[0];
		String attr = arr[1];
		System.out.println(tableAndId + ' ' + attr);
		context.write(new Text(attr), new Text(tableAndId));
	}

}
